package com.tzbank.back.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.transaction.annotation.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.tzbank.back.dao.ModuleMapper;
import com.tzbank.back.service.ModuleService;
import com.tzbank.entity.backstage.Module;
import com.tzbank.utils.CodeUtil;
import com.tzbank.utils.ResultUtil;

@Service
public class ModuleServiceImpl implements ModuleService {

	@Autowired
	private ModuleMapper moduleMapper;

	@Transactional
	@Override
	public Map<String, Object> deleteModule(Module module) throws Exception{
		this.moduleMapper.deleteModule(module);
		return ResultUtil.resultMap(CodeUtil.CODE_200.getName(), CodeUtil.CODE_200.getCode(), null);
	}

	@Transactional
	@Override
	public Map<String, Object> insertModule(Module module) throws Exception{
		this.moduleMapper.insertModule(module);
		return ResultUtil.resultMap(CodeUtil.CODE_200.getName(), CodeUtil.CODE_200.getCode(), null);
	}

	@Override
	public Map<String, Object> selectModuleByAutoId(int autoId) throws Exception{
		Module module = this.moduleMapper.selectModuleByAutoId(autoId);
		return ResultUtil.resultMap(CodeUtil.CODE_200.getName(), CodeUtil.CODE_200.getCode(), module);
	}

	@Override
	public Map<String, Object> selectModuleList() throws Exception{
		List<Module> modules = this.moduleMapper.selectModuleList();
		return ResultUtil.resultMap(CodeUtil.CODE_200.getName(), CodeUtil.CODE_200.getCode(), modules);
	}

	@Transactional
	@Override
	public Map<String, Object> updateModule(Module module) throws Exception{
		this.moduleMapper.updateModule(module);
		return ResultUtil.resultMap(CodeUtil.CODE_200.getName(), CodeUtil.CODE_200.getCode(), null);
	}

}
